package com.gouwudai.table.view.style1;

import org.extremecomponents.table.core.TableConstants;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.view.html.BuilderUtils;
import org.extremecomponents.table.view.html.TableActions;

public class UserTableActions extends TableActions {
    private TableModel model2;
	public UserTableActions(TableModel model) {
		super(model);
		this.model2=model;
	}

	public String getPageLinkAction() {
		StringBuffer action = new StringBuffer("javascript:");

		action.append(getClearedExportTableIdParameters());
		action.append(getPageLinkFormParameter(TableConstants.PAGE));
		action.append(getOnInvokeAction());

		return action.toString();
	}

	protected String getPageLinkFormParameter(String name) {
		StringBuffer result = new StringBuffer();

		String form = BuilderUtils.getForm(model2);
		String selectedOption = "this.options[this.selectedIndex].value";
		result.append("document.forms.").append(form).append(".");
		result.append(model2.getTableHandler().prefixWithTableId()).append(name);
		result.append(".value=").append(selectedOption).append(";");

		return result.toString();
	}
}
